import request from "@/utils/request";
import type { UserInfo } from '../types/user'
import type { ListResult, SearchParams } from "@/types/public";


// 获取用户登录详细信息
export const getUserInfoApi = () => {
    // 如果返回的是数组格式 UserInfo改为UserInfo[]
    return request<UserInfo>({
        method: 'get',
        url: '/api/user/info',
    })
}

// 获取用户列表
export const getUserListApi = (params: SearchParams) => {
    return request<ListResult<UserInfo>>({
        method: 'get',
        url: '/api/user',
        params
    })
}

//新建用户
export const createUserApi = (data: FormData) => {
    return request({
        method: 'post',
        url: '/api/user',
        data
    })
}

//编辑用户
export const updateUserApi = (id: number, data: FormData) => {
    return request({
        method: 'put',
        url: `/api/user/${id}`,
        data
    })
}